package com.gitee.dolt.utils.excel.importd;

import cn.hutool.poi.excel.ExcelUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 返回数据类型
 *
 * @author LYH
 */
@Data
@Accessors(chain = true)
public class ExcelErrorInfo implements Serializable {
    /**
     * 行
     */
    private Integer rowIndex;
    /**
     * 列
     */
    private Integer cellIndex;
    /**
     * 错误信息
     */
    private String errorMsg;
    /**
     * 字母列
     */
    private String cellText;
    /**
     * 数据
     */
    private Object data;

    public ExcelErrorInfo(Integer rowIndex, Integer cellIndex, String errorMsg, Object data) {
        this.rowIndex = rowIndex;
        this.cellIndex = cellIndex;
        this.errorMsg = errorMsg;
        this.data = data;
        if (cellIndex != null) {
            this.cellText = ExcelUtil.indexToColName(cellIndex);
        }
    }

    public static ExcelErrorInfo valueOf(Integer rowIndex, Integer cellIndex, String errorMsg, Object data) {
        return new ExcelErrorInfo(rowIndex, cellIndex, errorMsg, data);
    }

    public static ExcelErrorInfo valueOf(Integer rowIndex, Integer cellIndex, String errorMsg) {
        return valueOf(rowIndex, cellIndex, errorMsg, null);
    }

    public static ExcelErrorInfo valueOf(Integer rowIndex, String errorMsg) {
        return valueOf(rowIndex, null, errorMsg);
    }


}
